/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef MACHINEUNIT_H_
#define MACHINEUNIT_H_

#include <vector>
#include <string>
#include "wx/wx.h"
//#define GIMI_CLIENT_API 20000
#include "gimi.h"
#include "Types.hpp"

/**
Describes a unit that uses MaCI, eg. single robot or avant

Unit has device layers for different types of devices it can have.
Each unit adds its own actions menu in components main menu.
*/

namespace MaCIGUI
{

class CDeviceLayer;

class CMachineUnit
{
  public:
    CMachineUnit(std::string groupName, gimi::GIMI *gimi);

    ~CMachineUnit();
    
    void Update();

    void Draw(float viewLeft, float viewRight, float viewTop, float viewBottom, 
              float scale);

    void OnClick(float x, float y);
    void OnKey(int KeyCode);
    void OnKeyUp(int keyCode);
    void OnKillFocus();
    
    bool AddService(const Gimbo::TServiceAssignment &service, 
                    std::string aGroupName);
    
    //std::string gimName;
    std::string groupName;

    bool Selected;

    std::vector<CDeviceLayer*> DeviceLayers;

    /*reference layer describing units position,
    give this to other layers that are supposed to use units coordinates
    */
    CDeviceLayer* RefLayer;

    gimi::GIMI *gimi;
    //wxMenu Menu; //actions menu for client unit
    
  private:
    ownMutexHandle deviceMutex;
    //void initDevices();
};

}

#endif //MACHINEUNIT_H_
